package com.alfayun.fiscalriskanalysis.reportspec;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonIgnore;

@Entity
@Table(name = "report_template")
public class ReportTemplate {
	
	
	
	@Column(name = "report_template_id", updatable = false)
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Id
	private Integer id;
	public String name;
	@JsonIgnore
	@OneToMany(mappedBy = "template", fetch = FetchType.LAZY)
	public List<RowSpec> rows;
	@JsonIgnore
	@OneToMany(mappedBy = "template", fetch = FetchType.LAZY)
	public List<ColumnSpec> columns;
	//private List<CellSpec> cells;
	
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	
	public static ReportTemplate newReportTemplate(ReportTemplateRepository repository, ReportTemplate reportTemplate) {
		reportTemplate.id = 0;

		return repository.save(reportTemplate);
	}

}
